
////////////////////////////////////////////////////////////////////////////////////////////////
/* please refer to Appendix A2 for definitions and sources of all variables in the paper */
////////////////////////////////////////////////////////////////////////////////////////////////

/* load the bank-county-year data file */
*set appropriate directory
use "bank_county_year.dta", clear


***************************************
/* GEN DESCRIPTIVE STATS IN TABLE 1*/
***************************************

*generate loan-level characteristics 
outreg2 using loan_leveldescriptive.xls, replace sum(detail) keep( approve_rate  ln_originatedloan  totalapp_received amt_income amt_loan  loan_to_income fracfemale fracminor frac_samesex FICO CLTV defaults) eqkeep (N mean sd p25 p50 p75)

*below and above MW presence's median based on the bank_county_year sample    
outreg2 using loan_leveldescriptive1.xls if MW_presence>.0055372, replace sum(detail) keep( approve_rate  ln_originatedloan  totalapp_received amt_income amt_loan  loan_to_income fracfemale fracminor frac_samesex FICO CLTV defaults) eqkeep (N mean sd p25 p50 p75)
outreg2 using loan_leveldescriptive2.xls if MW_presence<=.0055372, replace sum(detail) keep( approve_rate  ln_originatedloan  totalapp_received amt_income amt_loan  loan_to_income fracfemale fracminor frac_samesex FICO CLTV defaults) eqkeep (N mean sd p25 p50 p75)

*generate bank-level characteristics 
sort                bankid year
quietly by      bankid  year  :  gen dup = cond(_N==1,0,_n)

outreg2 using bank_leveldescriptive.xls if dup<=1, replace sum(detail) keep(  LN_ASSETS   ROA  CAPITAL_RATIO  DEPOSIT_TO_ASSETS LOAN_TO_ASSETS  Realestate_loan ) eqkeep (N mean sd p25 p50 p75)
drop dup 


////////////////////////////////////
////////////////////////////////////
/* GEN REGRESSION RESULTS  */
////////////////////////////////////

////////////////////////////////////

*IMPORTANT* Need to run this command to set control variables before running any regressions 

*set control variables 
macro drop _all 

/*set control variables for regressions on MW banks */
global control_mw2     LN_ASSETS LN_ASSETS_SQR   ROA    CAPITAL_RATIO   DEPOSIT_TO_ASSETS LOAN_TO_ASSETS  Realestate_loan  ln_income loan_to_income     fracfemale fracminor   frac_samesex 

/*set control variables for regressions on banks without MW */
global control_spillover   LN_ASSETS LN_ASSETS_SQR   ROA  CAPITAL_RATIO  DEPOSIT_TO_ASSETS LOAN_TO_ASSETS  Realestate_loan  ln_income   loan_to_income   fracfemale fracminor   frac_samesex   LN_ASSETSPPOST  LN_ASSETS_SQRPOST ROAPOST CAPITAL_RATIOSPOST DEPOSIT_TO_ASSETSSPOST LOAN_TO_ASSETSPOST Realestate_loanPOST        ln_incomepost loan_to_incomePOST   fracfemalepost fracminorpost fracsamesexpost           
       
/*set control variables for regressions on loan performance (Table 8) */
global control_performance  LN_ASSETS LN_ASSETS_SQR   ROA  CAPITAL_RATIO  DEPOSIT_TO_ASSETS LOAN_TO_ASSETS  Realestate_loan  ln_income   loan_to_income   fracfemale fracminor   frac_samesex FICO CLTV  LN_ASSETSPPOST  LN_ASSETS_SQRPOST  ROAPOST CAPITAL_RATIOSPOST  DEPOSIT_TO_ASSETSSPOST LOAN_TO_ASSETSPOST Realestate_loanPOST        ln_incomepost loan_to_incomePOST   fracfemalepost fracminorpost fracsamesexpost           ficopost   cltvpost             



************************************
/* GEN RESULTS IN TABLES 2*/
************************************
reghdfe  ln_originatedloan post_2003   $control_mw2   if mw2==1, noabsorb vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan post_2003   $control_mw2   if mw2==1, absorb( countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/
reghdfe  ln_originatedloan post_2003   $control_mw2   if mw2==1  , absorb( bankid  countyFIPS ) vce(cluster countyFIPS )  keepsingletons /*Column 3*/



*******************************
/* GEN RESULTS IN TABLE 3*/
*******************************

***********
*PANEL A
***********
reghdfe  ln_originatedloan i.post_2003##c.demeaned_FICO   $control_mw2  if mw2==1, absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan i.post_2003##c.demeaned_CLTV    $control_mw2   if mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 2*/ 
reghdfe  ln_originatedloan i.post_2003##c.demeaned_default0002     $control_mw2   if  mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 3*/



***********
*PANEL B
***********
reghdfe  ln_originatedloan i.post_2003##c.demeaned_ln_income     $control_mw2   if mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan i.post_2003##c.demeaned_fracfemale     $control_mw2   if mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 2*/
reghdfe  ln_originatedloan i.post_2003##c.demeaned_fracminor     $control_mw2   if mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 3*/
reghdfe  ln_originatedloan i.post_2003##c.demeaned_frac_samesex     $control_mw2   if mw2==1 , absorb(bankid countyFIPS )  vce(cluster countyFIPS)  keepsingletons /*Column 4*/



*******************************
/* GEN RESULTS IN TABLE 5*/
*******************************

reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence   $control_spillover      if nonmw2_public==1 , absorb( year  countyFIPS  ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if nonmw2_public==1 , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/

reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence   $control_spillover      if private==1, absorb( year  countyFIPS  ) vce(cluster countyFIPS)  keepsingletons /*Column 3*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover       if private==1 , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 4*/



*******************************
/* GEN RESULTS IN TABLE 6*/
*******************************
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_HHI_originatedloans   $control_spillover      if nonmw2_public ==1, absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_HHI_originatedloans   $control_spillover      if  private==1 , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/


*******************************
/* GEN RESULTS IN TABLE 7*/
******************************* 	
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_FICO   $control_spillover      if nonmw2_public ==1  , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_CLTV   $control_spillover      if nonmw2_public ==1  , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_default0002   $control_spillover      if nonmw2_public ==1  , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 3*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_FICO   $control_spillover      if private==1 , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 4*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_CLTV  $control_spillover      if private==1  , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 5*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_default0002    $control_spillover      if private==1   , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 6*/

*******************************
/* GEN RESULTS IN TABLE 8*/
*******************************    

reghdfe  defaults  i.post_2003##c.deameanedMW_presence     $control_performance    if  nonmw2_public ==1   , absorb(bankid year countyFIPS  ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  defaults  i.post_2003##c.deameanedMW_presence   $control_performance  if private==1    , absorb(bankid year countyFIPS  ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/


*******************************
/* GEN RESULTS IN APPENDIX A4*/
*******************************   


***********
*PANEL A
***********
reghdfe  ln_originatedloan before_2001   is2003 is2004 is2005 post2006 $control_mw2   if mw2==1 , absorb(bankid countyFIPS ) vce(cluster  countyFIPS)  keepsingletons

***********
*PANEL B
***********
reghdfe  ln_originatedloan post_2003   $control_mw2   if mw2==1  & incomegrowth_diff<  0    , absorb( bankid  countyFIPS ) vce(cluster countyFIPS )  keepsingletons


***********
*PANEL C
***********
reghdfe  ln_originatedloan i.post_2003##c.demeaned_lti   $control_mw2   if mw2==1  & incomegrowth_diff<  0    , absorb( bankid  countyFIPS ) vce(cluster countyFIPS )  keepsingletons


***********
*PANEL D
***********
reghdfe  ln_appreceived post_2003 $control_mw2   if mw2==1, absorb(bankid countyFIPS ) vce(cluster countyFIPS)  keepsingletons


***********
*PANEL E
***********
reghdfe  ln_originatedloan post_2003   $control_mw2   if mw2==1  & dependent_boards==0, absorb(bankid countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan post_2003   $control_mw2      if mw2==1  &  bankid!=1039454  &  bankid!=1075126  & bankid!=2961879 , absorb(bankid countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/
reghdfe  ln_originatedloan post_2003   $control_mw2  ln_population ln_incomepercap county_uemployrate  HHI_originatedloans  if mw2==1  , absorb(bankid countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 3*/





*******************************
/* GEN RESULTS IN APPENDIX A5*/
*******************************  
***********
*PANEL A
***********
reghdfe  ln_originatedloan i.before_2001##c.deameanedMW_presence i.is2003##c.deameanedMW_presence     i.is2004##c.deameanedMW_presence    i.is2005##c.deameanedMW_presence     i.post2006##c.deameanedMW_presence   $control_spillover    if  nonmw2_public ==1   , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/

reghdfe  ln_originatedloan i.before_2001##c.deameanedMW_presence i.is2003##c.deameanedMW_presence     i.is2004##c.deameanedMW_presence    i.is2005##c.deameanedMW_presence     i.post2006##c.deameanedMW_presence    $control_spillover  if private==1 , absorb(bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/



***********
*PANEL B
*********** 
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if nonmw2_public==1 & incomegrowth_diff<  0  , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if  private==1 &  incomegrowth_diff<  0  , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/


***********
*PANEL C
*********** 

reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_lti  $control_spillover      if nonmw2_public==1 & incomegrowth_diff<  0  , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence##c.demeaned_lti    $control_spillover      if  private==1 & incomegrowth_diff<  0  , absorb( year  countyFIPS  ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/




***********
*PANEL D
*********** 
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if nonmw2_public==1 &   LN_ASSETS>   16.53829           , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 1*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if   nonmw2_public==1 &  LN_ASSETS<=   16.53829         , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 2*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if nonmw2_public==1 &  bankid!=1073757 &  bankid!=1120754 &  bankid!=  1951350 &  bankid!= 1039502, absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 3*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence i.post_2003##i.size_decile $control_spillover      if nonmw2_public==1 , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*Column 4*/




***********
*PANEL E
*********** 
reghdfe  ln_originatedloan   i.post_2003##c.ln_MWPresence $control_spillover      if nonmw2_public==1 , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 1*/
reghdfe  ln_originatedloan   i.post_2003##c.ln_MWPresence $control_spillover      if  private==1  , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 1*/


reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if   nonmw2_public==1 & MW_presence>0, absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 2*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if private==1 & MW_presence>0, absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 2*/


reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover      if nonmw2_public==1 & MW_presence> .0005447    , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 3*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover     if private==1  & MW_presence> .0005447    , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 3*/


reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover i.post_2003##c.HHI_originatedloans      if nonmw2_public==1      , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 4*/
reghdfe  ln_originatedloan   i.post_2003##c.deameanedMW_presence $control_spillover   i.post_2003##c.HHI_originatedloans    if private==1   , absorb( bankid year countyFIPS ) vce(cluster countyFIPS)  keepsingletons /*row 4*/




